package main

import (
	"context"
	"fmt"
	"kee/handler"
	"os"
	"os/signal"
	"syscall"
)

var impl = new(handler.ImplKee)

func main() {

	ctx := context.Background()

	err := impl.InitKee(ctx)
	if err != nil {
		return
	}

	quit := make(chan os.Signal, 1)

	// SIGINT  用户发送INTR字符(Ctrl+C)触发
	// SIGTERM 结束程序(可以被捕获、阻塞或忽略)
	signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)

	go func() {
		err := impl.RequestEastMoneyData()
		// 运行完成退出
		if err != nil {
			fmt.Println(err.Error())
			os.Exit(0)
		}
	}()

	go func() {
		impl.StorageData()
	}()

	<-quit
	fmt.Println("end...")
}
